package com.ruoyi.system.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.ruoyi.system.domain.dto.UserDto;
import com.ruoyi.system.domain.vo.UserVo;
import com.ruoyi.system.mapper.UserMapper;
import com.ruoyi.system.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public Map getUserList(UserDto user) {
        PageHelper.startPage(user.getPageNum(),user.getPageSize());
        Page<UserVo> page = userMapper.getUserList(user);

        HashMap<String,Object> map = new HashMap<>();
        map.put("data",page.getResult());
        map.put("total",page.getTotal());

        return map;
    }

    //修改状态
    @Override
    public void changeStates(String userId, String states) {
         userMapper.changeStates(userId,states);
    }
}
